revision:
The property returns the viewable width of an element in pixels, including padding, but not the border, scrollbar or margin. The property is read-only.
Syntax:
element.clientWidth : the viewable width of an element (in pixels) including padding.
property value:
none:
example
<div>
<div id="DIV">
<b>Information about DIV:</b><br>
Height: 250px<br>
Width: 400px<br>
Padding: 10px<br>
Margin: 15px<br>
Border: 5px<br>
<p id="prop"></p>
</div>
</div>
<style>
#DIV{height: 250px; width: 400px; padding: 10px; margin: 15px; border: 5px solid red;
background-color: lightblue; }
</style>
<script>
const element = document.getElementById("DIV");
let text = "clientHeight: " + element.clientHeight + "px<br>";
text += "clientWidth: " + element.clientWidth + "px";
document.getElementById("prop").innerHTML = text;
</script>
<div id="DIV1">
<b>Information about this div:</b><br>
Height: 250px<br>
Width: 400px<br>
Padding: 10px<br>
Margin: 15px<br>
Border: 5px<br>
<p id="prop1"></p>
</div>
<style>
#DIV1 {height: 250px; width: 400px; padding: 10px; margin: 15px; border: 5px solid red;
background-color: lightblue;}
</style>
<script>
const element1 = document.getElementById("DIV1");
let text1 = "";
text1 += "clientHeight: " + element.clientHeight + "px<br>";
text1 += "offsetHeight: " + element.offsetHeight + "px<br>";
text1 += "clientWidth: " + element.clientWidth + "px<br>";
text1 += "offsetWidth: " + element.offsetWidth + "px";
document.getElementById("prop1").innerHTML = text;
</script>